package com.wltt.product.frfront.controller;

import com.wltt.product.frfront.model.ResultData;
import com.wltt.product.frfront.model.vo.*;
import com.wltt.product.frfront.service.RobotService;
import jakarta.annotation.Resource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/api/robot")
public class RobotController {

    private static final Logger logger = LogManager.getLogger(RobotController.class);


    @Resource
    private RobotService robotService;

    /**
     * 获取位置信息
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/getPosition"}, method = RequestMethod.POST)
    public ResultData getPosition() {
        return robotService.getPosition();
    }

    /**
     * 获取单次运行最大值
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/getMaxStep"}, method = RequestMethod.POST)
    public ResultData getMaxStep() {
        return robotService.getMaxStep();
    }

    /**
     * 设置单次运行最大值
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/setMaxStep"}, method = RequestMethod.POST)
    public ResultData setMaxStep(@RequestBody SetMaxStepREQ setMaxStepREQ) {
        return robotService.setMaxStep(setMaxStepREQ);
    }

    /**
     * 获取坐标系
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/coordinateSystem"}, method = RequestMethod.POST)
    public ResultData coordinateSystem() {
        return robotService.coordinateSystem();
    }

    /**
     * 关节控制
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/JointMove"}, method = RequestMethod.POST)
    public ResultData JointMove(@RequestBody JointMoveREQ jointMoveREQ) {
        return robotService.JointMove(jointMoveREQ);
    }

    /**
     * 位姿控制
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/poseMove"}, method = RequestMethod.POST)
    public ResultData poseMove(@RequestBody PoseMoveREQ poseMoveREQ) {
        return robotService.poseMove(poseMoveREQ);
    }

    /**
     * 运动停止
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/moveStop"}, method = RequestMethod.POST)
    public ResultData moveStop() {
        return robotService.moveStop();
    }

    /**
     * 清楚报警
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/cleanWarn"}, method = RequestMethod.POST)
    public ResultData cleanWarn() {
        return robotService.cleanWarn();
    }

    /**
     * 获取运行信息
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/runInfo"}, method = RequestMethod.POST)
    public ResultData runInfo() {
        return robotService.runInfo();
    }


    /**
     * 获取工具坐标号
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/getToolCoordinateNum"}, method = RequestMethod.POST)
    public ResultData getToolCoordinateNum() {
        return robotService.getToolCoordinateNum();
    }

    /**
     * 设置工具坐标号
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/setToolCoordinateNum"}, method = RequestMethod.POST)
    public ResultData setToolCoordinateNum(@RequestBody SetToolCoordinateNumREQ setToolCoordinateNumREQ) {
        return robotService.setToolCoordinateNum(setToolCoordinateNumREQ);
    }

    /**
     * 获取工件坐标号
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/getWorkpieceCoordinateNum"}, method = RequestMethod.POST)
    public ResultData getWorkpieceCoordinateNum() {
        return robotService.getWorkpieceCoordinateNum();
    }

    /**
     * 设置工件坐标号
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/setWorkpieceCoordinateNum"}, method = RequestMethod.POST)
    public ResultData setWorkpieceCoordinateNum(@RequestBody SetWorkpieceCoordinateNumREQ setWorkpieceCoordinateNumREQ) {
        return robotService.setWorkpieceCoordinateNum(setWorkpieceCoordinateNumREQ);
    }
}

